home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / interp / tclStruct1.2.tar.gz / tclStruct1.2.tar / tclStruct1.2 / struct.tcl < prev    next >
Text File  |  1995-09-12  |  1KB  |  58 lines

  1. #     struct.rc (for Tcl)
  2. puts {Testing the use of 'struct' with Tcl
  3. }
  4. #struct_info debug +refcount
  5.  
  6. set intrinsic [struct_info types]
  7.  
  8. puts {
  9.     Sizes of types}
  10. foreach type $intrinsic {
  11.     puts "Size of $type is [struct_info sizeof $type]"
  12. }
  13.  
  14. puts ""
  15. puts "Defining structure ..."
  16. #struct_info debug +all
  17. struct_typedef combined {struct
  18.     {int anint}
  19.     {ushort ashort}
  20.     {char achar1}
  21.     {char achar2}
  22.     {^short aptr}
  23. }
  24. puts "Display size ..."
  25. puts "Size of combined is [struct_info sizeof combined]"
  26.  
  27. puts "Allocate object"
  28. puts [struct_new obj combined]
  29. puts "okay"
  30. #struct_info debug +all
  31. foreach elem {aptr aptr._hex_} {
  32.     puts "  obj($elem) = '$obj($elem)'"
  33. }
  34.  
  35. #struct_info debug -all +refcount
  36. puts "Size of obj is [struct_info sizeof obj]"
  37. puts "Size of combined is [struct_info sizeof combined]"
  38. # struct_info debug +all
  39. set obj(_char_) {ABCDEFGHIJKL}
  40.  
  41. foreach elem {_hex_ anint ashort achar1 achar2 ashort._hex_ achar2._hex_ ashort._char_ _char_} {
  42.     puts "  obj($elem) = '$obj($elem)'"
  43. }
  44.  
  45. puts ""
  46. # struct_typedef linebuf char*32
  47. struct_new linebuf char*32
  48. foreach elem {_hex_ 2 2._hex_} {
  49.     puts "  linebuf($elem) = '$linebuf($elem)'"
  50. }
  51.  
  52. #struct_info debug +all
  53. puts "  obj() = '$obj()'"
  54.  
  55. struct_typedef link1 {struct {^link1 next} {int count}}
  56.  
  57. # exit
  58.